package com.egg.demo.controller.web;

import com.egg.common.core.model.controller.WebController;
import com.egg.common.core.model.response.ResponseData;
import com.egg.demo.model.request.TestPost;
import com.egg.demo.service.test.ITestService;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@Api(tags = WebController.API_PREFIX + "分布式事务")
@RestController
@RequestMapping("/seata")
public class WebGlobalTransactionalController extends WebController {


    @Autowired
    private ITestService testService;


    @GlobalTransactional
    @ApiOperation(value = "回滚")
    @PostMapping("/rollback")
    public ResponseData<Long> rollback(@RequestBody TestPost param) {
        testService.globalTransactional(param);
        return ResponseData.success();
    }


}

